package main

import "fmt"

type person interface {
	SayHello() string
}

type Student struct {
	Name string
	Age int
}

func (s Student) SayHello() string {
	return "Student:Hello!"
}

type Teacher struct {
	Name string
	Age int
}

func (t *Teacher) SayHello() string {
	return "Teacher:Hello!"
}

func main() {
	//结构体方法指针接收时候，赋值给实现接口只能是指针类型
	var stuPerson person
	var teaPerson person
	stuPerson = Student{"zhe",14}
	teaPerson = &Teacher{"teacher",15}
	//Teacher 方法接收是指针所以实现接口的赋值必须是指针类型，如下是错误写法
	//teaPerson = Teacher{"teacher",15}

	fmt.Println(stuPerson)
	fmt.Println(teaPerson)

}
